package com.bbc.wigeth;

import android.animation.ObjectAnimator;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by Administrator on 2017/9/29.
 */

public class MyPerView extends View {
    private int pre = 0;
    private Paint mPaint;
    private View view;

    public int getPre() {
        return pre;
    }

    public void setPre(int pre) {
        this.pre = pre;
        invalidate();
    }

    public MyPerView(Context context) {
        super(context, null);
    }

    public MyPerView(Context context, AttributeSet attrs) {
        super(context, attrs);
        view = new MyPerView(context);
        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mPaint.setColor(Color.RED);
        mPaint.setStrokeWidth(20);
        // 创建 ObjectAnimator 对象
        ObjectAnimator animator = ObjectAnimator.ofFloat(view, "progress", 0, 65);
// 执行动画
        animator.start();
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.drawArc(new RectF(100, 50, 100, 50), 135, (float) (pre * 2.7), false, mPaint);
    }


}
